/**
 * 
 */
package com.yidu.menuProject.action;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.menuProject.action.vo.SiteAndUser;
import com.yidu.menuProject.model.SiteModel;
import com.yidu.menuProject.model.TuserModel;
import com.yidu.menuProject.service.SiteService;
/**
 * 类的描述--地址的action
 * @author sylval
 * @date 2018年7月19日 下午7:56:12
 * @version 1.0
 */
@Controller
@RequestMapping("/siteAction")
public class SiteAction {
	@Resource
	SiteService Sise;
	
	/**
	 * 增加地址
	 * @param record
	 * @return
	 */
	@RequestMapping("/addOrUpdateSite")
	@ResponseBody
	public int addOrUpdateSite(SiteModel record,HttpSession session){
		TuserModel tuserModel=(TuserModel) session.getAttribute("tuserModel");
		record.setUserId(tuserModel.getUserId());
		int site=Sise.insertSelectiveOrUpdate(record);
		return site;
	}
	
	/**
	 * 删除地址
	 * @param record
	 * @return
	 */
	@RequestMapping("/deleteSite")
	@ResponseBody
	public int deleteSite(String siteId){
		int site=Sise.deleteByPrimaryKey(siteId);
		return site;
	}
	
	/**
	 * 查询地址
	 * @param record
	 * @return
	 */
	@RequestMapping("/findAll")
	@ResponseBody
	public List<SiteAndUser> findAll(HttpSession session){
		TuserModel tuserModel=(TuserModel) session.getAttribute("tuserModel");
		List<SiteAndUser> list=Sise.findAll(tuserModel.getUserId());
		return list;
	}
	/**
	 * 根据主键查询地址信息
	 * @param siteId
	 * @return
	 */
	@RequestMapping("/selectByPrimaryKey")
	@ResponseBody
	public SiteModel selectByPrimaryKey(String siteId){
		SiteModel site=Sise.selectByPrimaryKey(siteId);
		return site;
	}
}
